from operator import mod
from tabnanny import verbose
from django.db import models
from django.forms import CharField

# Create your models here.

class Admin(models.Model):
    aname=models.CharField(verbose_name='姓名',max_length=20)
    password=models.CharField(verbose_name='密码',max_length=64)

class Supplier(models.Model):
    sname=models.CharField(verbose_name='供应商',max_length=20)
    smobile=models.CharField(verbose_name='联系方式',max_length=11)
    def __str__(self):
        return self.sname

class Purify_water(models.Model):
    pname=models.CharField(verbose_name="纯净水名称",max_length=20)
    num=models.IntegerField(verbose_name='库存量')
    price=models.IntegerField(verbose_name='单价')
    supplier=models.ManyToManyField(Supplier)
    state_choices=(
        (1,"有库存"),
        (2,"缺货")
    )
    state=models.SmallIntegerField(verbose_name="库存状态",default=1)

class Order(models.Model):
    oid=models.CharField(verbose_name="订单编号",max_length=30)
    # cid=models.Ch)arField(verbose_name="客户编号",max_length=30)
    cname=models.CharField(verbose_name="客户姓名",max_length=30)
    pname=models.CharField(verbose_name="纯净水",max_length=20)
    num=models.IntegerField(verbose_name="数量")
    take=models.IntegerField(verbose_name="支付")
    state_choices=(
        (1,"已支付"),
        (2,"未支付")
    )
    state=models.SmallIntegerField(verbose_name="状态",choices=state_choices,default=1)
    state2_choices=(
        (1,"申请"),
        (2,"已申请")
    )
    state2=models.SmallIntegerField(verbose_name="状态",choices=state2_choices,default=1)
   
   


class Client(models.Model):
    cname=models.CharField(verbose_name='姓名',max_length=20)
    caddr=models.CharField(verbose_name='地址',max_length=50)
    cmobile=models.CharField(verbose_name='联系方式',max_length=11)
    Purify_waters=models.ManyToManyField(Purify_water)
    # order=models.ForeignKey(Order,on_delete=models.CASCADE)

class Water_workers(models.Model):
    
    wname=models.CharField(verbose_name='姓名',max_length=20)
    base_salary=models.IntegerField(verbose_name='底薪')
    password=models.CharField(verbose_name='密码',max_length=64)
    commision=models.DecimalField(verbose_name='提成',max_digits=5,decimal_places=4)
    salary=models.DecimalField(verbose_name="工资累计",max_digits=6,decimal_places=2)

class Role(models.Model):
    role_choice=(
        (1,"管理员"),
        (2,"送水工")
    )
    role=models.SmallIntegerField(verbose_name="角色",choices=role_choice)
class Order_examine(models.Model):
    wid=models.CharField(verbose_name="送水工编号",max_length=10)
    wname=models.CharField(verbose_name="送水工姓名",max_length=30)
    cname=models.CharField(verbose_name="客户姓名",max_length=30)
    oid=models.CharField(verbose_name="订单编号",max_length=30)
    pname=models.CharField(verbose_name="纯净水",max_length=20)
    num=models.IntegerField(verbose_name="数量",default=0)
    state_choices=(
        (1,"未审核"),
        (2,"已审核")
    )
   
    state=models.SmallIntegerField(verbose_name="状态",choices=state_choices,default=1)
    state1_choices=(
        (1,'未完成'),
        (2,'完成'),
        (3,'派送中')
    )
    state1=models.SmallIntegerField(verbose_name="状态",choices=state1_choices,default=1)
    state3_choices=(
        (1,"未申请"),
        (2,"审核中"),
        (3,"通过"),
        (4,"未通过")
    )
    state3=models.SmallIntegerField(verbose_name="状态",choices=state3_choices,default=1)

class Purchase(models.Model):
    pname=models.CharField(verbose_name="纯净水名称",max_length=20)
    num=models.IntegerField(verbose_name='进货量')

   


   